<template>
  <a-layout>
    <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible>
      <div class="logo" />
      <a-menu v-model:selectedKeys="state.selectedKeys" :items="items" theme="dark"
      @click="clickItem"
        mode="inline">
      </a-menu>
    </a-layout-sider>
    <a-layout>
      <!-- <a-layout-header style="background: #fff; padding: 0">
        <menu-unfold-outlined v-if="collapsed" class="trigger" @click="() => (collapsed = !collapsed)" />
        <menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
      </a-layout-header> -->
      <a-layout-content :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }">
        <router-view :key="$route.fullPath"></router-view>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>
<script lang="ts" setup>
import { ref, reactive, h, watch } from 'vue';
import {useRouter, useRoute} from 'vue-router'
import {menuData} from '../src/stores/menudata'

const collapsed = ref<boolean>(false);
const router = useRouter()
const clickItem = (item:any) => {
  console.log(item)
  router.push({
    path:item.item.route,
    query: {
      method:item.item.method,
      encode:item.item.encode,
      title: item.item.title
    }
  })
}
const state = reactive({
  collapsed: false,
  selectedKeys: []
});
const items = reactive(menuData);
</script>
<style>
html,
body,
#app {
  height: 100%;
}

#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.3);
  margin: 16px;
}

.site-layout .site-layout-background {
  background: #fff;
}

.ant-layout {
  display: flex;
  width: 100%;
  min-height: 100%;
}
</style>